package com.devops.admin.config;

import com.devops.admin.job.AutowiringSpringBeanJobFactory;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * @author jxt
 * @Notes
 * @date 2024/1/10 10:43
 */
public class JobFactoryConfig {
    @Bean
    public AutowiringSpringBeanJobFactory autowiringSpringBeanJobFactory() {
        return new AutowiringSpringBeanJobFactory();
    }

    @Bean
    public SchedulerFactoryBean scheduler(Trigger[] triggers, JobDetail[] jobDetails, AutowiringSpringBeanJobFactory jobFactory) {
        SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean();
        schedulerFactory.setJobFactory(jobFactory);
        schedulerFactory.setTriggers(triggers);
        schedulerFactory.setJobDetails(jobDetails);
        return schedulerFactory;
    }
}
